import yagmail

mail_address = "zhanghze_03@163.com"
mail_host = "smtp.163.com"
mail_port = 465
mail_password = "YIIEVPHLOFAMZCFC"

def sendmail(to_user: list, 
             subject: str, 
             text: str, 
             att=None):
    if isinstance(to_user, (str, list)) and isinstance(subject, str) and isinstance(text, str):
        ## 初始化邮件服务器对象
        smtp = yagmail.SMTP(user=mail_address,
                     password=mail_password,
                     host=mail_host,
                     port=mail_port,
                     smtp_ssl=True)
        smtp.send(to=to_user, subject=subject, contents=text, attachments=att)
    else:
        raise TypeError("参数类型错误")

data = '''
亲爱的吃瓜群众们，最近娱乐圈又热闹起来了，话题的中心人物不是别人，正是那位从不让我们失望的热议大王——王思聪，俗话说男人的生活不能太寂寞，看来这位总裁又开启了他的“狗粮慈善模式”。这不，最近他和现任懒懒情侣装亮相人前，甜蜜度爆表，把爱意大方洒向了日本街头，甜蜜的样子让无数单身狗情何以堪！
'''

# 确保 to_user 是一个列表
sendmail(to_user=[mail_address], subject="千锋实习", text=data)